// NetworkTransmitter.hpp
#pragma once

#include "camera_manage_type.h"
#include <atomic>
#include <condition_variable>
#include <mutex>
#include <queue>
#include <string>
#include <thread>
#include <vector>
#include "Queue/Queue.hpp"

class NetworkTransmitter {
  public:
    NetworkTransmitter(int cameraId);
    ~NetworkTransmitter();

    bool initialize(const TransportConfig &config);
    int sendData(const NetworkFrameData &frameData);
    void sendUDP(const NetworkFrameData &frameData);
    void sendLocalSocket(const NetworkFrameData &frameData);
    void updateConfig(const TransportConfig &config);
    void start();
    void stop();

  private:
    int m_cameraId;
    int m_socketFd;
    TransportConfig m_config;

    std::atomic<bool> m_running;
    std::thread m_sendThread;
    Queue<NetworkFrameData> m_sendQueue;

    void sendLoop();
    bool connectToServer();
    void closeSocket();
};